#!/bin/bash
#
# 安装好docker后，添加一个本地docker.registry给该docker，

step=1
echo -e "\n******** step $step set harbor IP:port ********"
# 2. 指定docker.registry主机ip
read -p "Enter your harbor IP:port.example:192.168.3.1:8081. : " reply
if [ -z "$reply" ]; then
	reply="127.0.0.1:8081"
fi
echo "your docker.registry host ip is: $reply"


let step=step+1
echo "\n******** step $step generate /etc/docker/daemon.json ********"
# 4. 配置镜像加速器(针对Docker客户端版本大于1.10.0的用户)
if [ ! -d /etc/docker ]; then
  sudo mkdir -p /etc/docker
fi
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "insecure-registries":["###"]
}
EOF

sed -i 's/###/'$reply'/g'  /etc/docker/daemon.json
sudo systemctl daemon-reload


echo "config harbor success! /etc/docker/daemon.json content:"
cat /etc/docker/daemon.json

